<?php
namespace App\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){


            //dump($classify);exit;
        $this->display();

    }

    public function add()
    {
        $classify=M('Prodcates')->select();
        //$rom=M('Goods')->group('gcats')->select();
        foreach ($classify as $k =>$v){
            $classify[$k]['ros']=M('Goods')->where(['gcats'=>$v['id']])->select();
        }
        //$datas=M('Cart')->select();
        $model=M('Cart');
        $datas=$model->alias('a')->field('a.goods_number,b.gname')
            ->join('__GOODS__ b ON a.goods_id=b.id')
            ->select();

        $count = $model->sum('goods_number');
        $money=$model->sum('price');

        //dump($count);exit;

        //dump($classify);exit; 

        $this->assign(array(
            'classify'=>$classify,
            'datas'=>$datas,
            'count'=>$count,
            'money'=>$money
        ));


        $this->display();
    }


public function submit(){
    $cart = M('cart');
    $rom=$cart->select();
    foreach ($rom as $key => $value) {
        $rom[$key]['title'] = M('goods')->where('id='.$value['goods_id'])->find();
    }
    $this->assign('rom',$rom);
    //dump($rom);exit;
    $this->display();
}

}